package com.atcd.jdies.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
public class redisTestController {
//    ValueOperations<String,String> stringRedis;
    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    @GetMapping("/redis")
    public  String testRedis(){

        //设置值到redis
     redisTemplate.opsForValue().set("name","jack");
     //从redis获取值
        String name = redisTemplate.opsForValue().get("name");

        System.out.println("请求");
        return name;
    }
}
